<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8" />
        <title>订单支付-{eyou:global name='web_name' /}</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
        <link href="{eyou:global name='web_cmspath'/}/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        {eyou:static file="users/skin/css/basic.css" /}
        {eyou:static file="users/skin/css/eyoucms.css" /}
        {eyou:static file="users/skin/css/element/index.css" /}
        {eyou:static file="users/skin/css/e-user.css" /}
        {eyou:include file="users/skin/css/diy_css.htm" /}
        {eyou:static file="/public/static/common/js/jquery.min.js"/}
        {eyou:static file="/public/plugins/layer-v3.1.0/layer.js"/}
        {eyou:static file="users/skin/js/global.js" /}
        {eyou:static file="/public/static/common/js/mobile_global.js"/}
    </head>

    <body>
        <div class="ey-header-status">
            <div class="header-status-l">
                <a href="javascript:history.go(-1)"><i class="el-icon-arrow-left"></i></a>
            </div>
            <div class="header-status-m">订单支付</div>
            <div class="header-status-r">
                <a href="{eyou:url link='user/Users/index' /}"><i class="el-icon-user"></i></a>
            </div>
        </div>
        <div class="h50"></div>

        <div class="ey-container">
            <div class="el-row p10 bgfff">
                <div class="order-row tc ">
                    <i class="el-icon-success"></i>
                </div>
                <div class="order-row tc">
                    <span class="info">订单提交成功！去付款咯~</span>
                </div>
                <div class="order-row">
                    订单号：
                    <span class="red">{$data.unified_number}</span>
                </div>
                <div class="order-row">
                    商品名称：
                    <span class="red">
                    {eq name='$data.transaction_type' value='2'}
                        {volist name='$data.order_details' id='goods'}
                        <span>
                            {$goods.product_name}&nbsp;
                            {volist name='$goods.product_spec_list' id='spec'}{$spec.value}&nbsp;{/volist}
                        </span>
                        {/volist}
                    {else /}
                        <span class="red">{$data.cause}</span>
                    {/eq}
                    </span>
                </div>
                <div class="order-row">
                    {eyou:if condition="!empty($data.points_shop_order)"}
                    应付总额：<span class="red">{$data.order_amount}</span>
                    {eyou:else/}
                    应付总额：<span class="red">￥{$data.unified_amount}元</span>
                    {/eyou:if}
                    {eyou:eq name="$data.transaction_type" value="1"}
                    <a href="{:url('user/Pay/pay_account_recharge', ['unified_number'=>$data['unified_number'],'money'=>$data['unified_amount']])}">(更改)</a>
                    {/eyou:eq}
                </div>
                <div class="order-row">
                    {eyou:if condition="!empty($data.eyCountdownTimes) && !empty($data.paymentExpire)"}
                    <p class="order-time">
                        <span>请在<span id="{$data.eyCountdownTimes}" style="color: red;"></span><span>内完成支付, 超时后将取消订单</span></span>
                    </p>
                    {/eyou:if}
                </div>
            </div>

            <div class="el-row p10 bgfff mt10">
                <div class="column-title">
                    <div class="column-name">{eyou:eq name="$data.use_pay_type" value="0"}未开启支付方式{eyou:else/}支付方式{/eyou:eq}</div>
                </div>
                {$data.PayTypeHidden}
                <div class="pay-type">
                    <div class="li_div">
                        <div class="pay-con pt10 pb10">
                            {$data.payTypeHidden}
                            {eyou:sppayapilist id='vo'}
                            {eyou:notempty name="$vo.pay_id"}
                            <label class="radio-label pt10 pb10 pl0 e-label mb0 radio-label-flex phpSelectPayRadio" data-type="zxzf_{$vo.pay_mark}" data-id="{$vo.pay_id}" data-mark="{$vo.pay_mark}" onclick="selectPayType(this);">
                                    <span><img class="pay_img" src="{$vo.pay_img}" alt="{$vo.pay_name}">{$vo.pay_name}</span>
                                    <input class="radio" type="radio" name='pay_id' value="{$vo.pay_id}" {eyou:eq name="$key" value="0"} checked {/eyou:eq}>
                                    <span class="check-mark ri0"></span>
                            </label>
                            {/eyou:notempty}
                            {$vo.hidden}
                            {/eyou:sppayapilist}
                            <input type="hidden" id="PayID">
                            <input type="hidden" id="PayMark">
                            {eyou:if condition="empty($data.shop_open_offline) && empty($data.PromType) && empty($data.onlyVerify) && 2 == $data.transaction_type"}
                            <label class="radio-label pt10 pb10 pl0 mb0 e-label radio-label-flex phpSelectPayRadio" data-type="hdfk_payOnDelivery" data-id="0" data-mark="payOnDelivery" onclick="selectPayType(this);">
                                <span><img class="pay_img" src="{eyou:static file='users/skin/images/hdfk.png' /}" alt="货到付款">货到付款 </span>
                                <input class="radio" type="radio" name='pay_id' value="0">
                                <span class="check-mark ri0"></span>
                            </label>
                            {/eyou:if}
                            {eyou:if condition="1 != $data.transaction_type && 1 == $data.pay_balance_open"}
                            <label class="radio-label pt10 pb10 pl0 mb0 e-label radio-label-flex phpSelectPayRadio" data-type="yezf_balance" data-id="0" data-mark="balance" onclick="selectPayType(this);">
                                <span><img class="pay_img" src="{eyou:static file='users/skin/images/pay_yiyou.png' /}" alt="余额支付">余额支付 <span class="fc9 f14">可用{$users.users_money} 元</span></span>
                                <input class="radio" type="radio" name='pay_id' value="0">
                                <span class="check-mark ri0"></span>
                            </label>
                            {/eyou:if}
                        </div>
                    </div>
                </div>
            </div>

            <div class="el-row p10 bgfff mt10">
                <div class="handle-action">
                    <div class="operating-button">
                        <a href="javascript:void(0);" class="btn btn-primary" onclick="submitSelectPay(this);">去结算</a>
                    </div>
                </div>
            </div>
        </div>
        <script type="text/javascript">
            // 倒计时
            var paymentExpire = "{$data.paymentExpire}";
            var eyCountdownTimes = "{$data.eyCountdownTimes}";
            if (paymentExpire > 0) {
                executeCountdownTimes(paymentExpire);
            }
            function executeCountdownTimes(ey_totalSeconds) {
                // 取模（余数）
                var modulo = parseInt(ey_totalSeconds) % (60 * 60 * 24);
                // 小时数
                var hours = Math.floor(modulo / (60 * 60));
                modulo = modulo % (60 * 60);
                // 分钟
                var minutes = Math.floor(modulo / 60);
                // 秒数
                var seconds = parseInt(ey_totalSeconds % 60, 10);
                // 输出到页面
                $('#' + eyCountdownTimes).html(hours + "小时" + minutes + "分" + seconds + "秒");
                // 剩余秒数
                ey_totalSeconds--;
                // 倒计时结束则刷新页面
                if (parseInt(ey_totalSeconds) <= -1) {
                    window.location.reload();
                } else {
                    // 延迟一秒执行自己
                    setTimeout(function () {
                        executeCountdownTimes(ey_totalSeconds);
                    }, 1000);
                }
            }

            function submitSelectPay(obj) {
                // 禁止再次点击提交
                $(obj).prop("disabled", true).css("pointer-events", "none");

                // 支付参数
                var pay_id = $('#PayID').val();
                var pay_mark = $('#PayMark').val();
                // 微信支付、支付宝支付、第三方支付
                if (parseInt(pay_id) > 0 && pay_mark) SelectPayMethod(pay_id, pay_mark);
                // 余额支付、货到付款
                if (parseInt(pay_id) === 0 && pay_mark) {
                    // 余额支付
                    if ('balance' == pay_mark) {
                        if (!unified_id || !unified_number || !transaction_type) layer.msg('订单支付参数缺失，刷新重试', {time: 1500});
                        showLayerLoad();
                        $.ajax({
                            type: 'post',
                            data: {unified_id: unified_id, unified_number: unified_number, transaction_type: transaction_type},
                            url : '{$RootDir}/index.php?m=user&c=PayApi&a=balance_payment&_ajax=1',
                            dataType: 'json',
                            success: function(res) {
                                layer.closeAll();
                                if (1 === parseInt(res.code)) {
                                    if (res.data.email) eyUnifiedSendRemind(res.data.email);
                                    if (res.data.mobile) eyUnifiedSendRemind(res.data.mobile);
                                    showLayerMsg(res.msg, 2, function() {
                                        window.location.href = res.url;
                                    });
                                } else {
                                    payIsRecharge(obj, res.msg, res.url);
                                }
                            },
                            error: function (e) {
                                layer.closeAll();
                                showLayerAlert(e.responseText);
                            }
                        });
                    }
                    // 货到付款
                    else if ('payOnDelivery' == pay_mark) {
                        if (!unified_id || !unified_number || !transaction_type) layer.msg('订单支付参数缺失，刷新重试', {time: 1500});
                        showLayerLoad();
                        $.ajax({
                            type: 'post',
                            data: {unified_id: unified_id, unified_number: unified_number, transaction_type: transaction_type},
                            url : '{$RootDir}/index.php?m=user&c=PayApi&a=payOnDelivery&_ajax=1',
                            dataType: 'json',
                            success: function(res) {
                                layer.closeAll();
                                if (1 === parseInt(res.code)) {
                                    if (res.data.email) eyUnifiedSendRemind(res.data.email);
                                    if (res.data.mobile) eyUnifiedSendRemind(res.data.mobile);
                                    showLayerMsg(res.msg, 2, function() {
                                        window.location.href = res.url;
                                    });
                                } else {
                                    showLayerAlert(res.msg);
                                }
                            },
                            error: function (e) {
                                layer.closeAll();
                                showLayerAlert(e.responseText);
                            }
                        });
                    }
                }

                // 解除再次点击提交
                $(obj).prop("disabled", false).css("pointer-events", "");
            }

            // 是否要去充值
            function payIsRecharge(obj, msg ,url) {
                showConfirmBox(msg, ['去充值', '其他方式支付'], function() {
                    // 去充值
                    window.open(url);
                    showConfirmBox('是否充值成功，立即支付？', ['立即支付', '其他方式支付'], function() {
                        // 立即支付
                        submitSelectPay(obj);
                    }, function(index) {
                        $(obj).prop("disabled", false).css("pointer-events", "");
                        layer.closeAll(index);
                    });
                }, function(index) {
                    $(obj).prop("disabled", false).css("pointer-events", "");
                    layer.closeAll(index);
                });
            }
        </script>
    </body>
</html>